package com.sx.core;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;

public class StaticValue {
	// 读取配置文件
	public static ResourceBundle coreconfig = ResourceBundle.getBundle("config");
	// 数据库连接地址
	public static final String DRIVER = coreconfig.getString("name");
	
	public static String getValue(String key){
		String value = null;
		Properties properties = new Properties();
		InputStream input = null;
		try {
			String path = ClassLoader.getSystemResource("config.properties").getPath().substring(1);
			input = new FileInputStream(path);
			properties.load(input);
			value = properties.getProperty(key);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(input!=null){
					input.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return value;
	}
	
	public  String getSystemValue(String key){
		String value = null;
		Properties properties = new Properties();
		InputStream input = null;
		try {
			input = this.getClass().getResourceAsStream("/config.properties");
			properties.load(input);
			value = properties.getProperty(key);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(input!=null){
					input.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return value;
	}
	//首页显示栏目
	public static final String Connection_Flag = "connectionflag";
	
	
}
